package com.haiyi.software.messgeExtension;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.xmlpull.v1.XmlPullParser;

public class ProviderExtensionUhead implements PacketExtensionProvider {

	public ProviderExtensionUhead() {

	}

	public PacketExtension parseExtension(XmlPullParser parser) {

		ExtensionUhead packet = new ExtensionUhead();

		try {

			boolean done = false;
			while (!done) {
				int eventType = parser.getEventType();

				if (eventType == XmlPullParser.START_TAG) {
					if (parser.getName().equals(packet.getElementName())) {
						// advance to text
						parser.next();
						packet.setValue(parser.getText());
					}
				}

				else if (eventType == XmlPullParser.END_TAG) {
					if (parser.getName().equals(packet.getElementName())) {
						done = true;
					}
				}

				parser.next();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return packet;
	}
}
